package org.lq.sm.view.employee;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FilenameFilter;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;

import com.eltima.components.ui.DatePicker;

public class V_empAdd extends JFrame {

	private JPanel contentPane;
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					V_empAdd frame = new V_empAdd();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public V_empAdd() {
		setTitle("维护员工");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 427, 446);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		panel.setBorder(new TitledBorder(null, "\u5458\u5DE5\u4FE1\u606F", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		contentPane.add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel label = new JLabel("工 号 : ");
		label.setBounds(23, 29, 54, 15);
		panel.add(label);
		
		textField = new JTextField();
		textField.setBounds(73, 26, 66, 21);
		panel.add(textField);
		textField.setColumns(10);
		
		JLabel label_1 = new JLabel("姓 名:");
		label_1.setBounds(23, 54, 54, 15);
		panel.add(label_1);
		
		textField_1 = new JTextField();
		textField_1.setBounds(73, 51, 129, 21);
		panel.add(textField_1);
		textField_1.setColumns(10);
		
		JLabel label_1_1 = new JLabel("电 话 :");
		label_1_1.setBounds(23, 82, 54, 15);
		panel.add(label_1_1);
		
		textField_2 = new JTextField();
		textField_2.setColumns(10);
		textField_2.setBounds(73, 79, 129, 21);
		panel.add(textField_2);
		
		JLabel label_1_2 = new JLabel("底 薪 :");
		label_1_2.setBounds(23, 113, 54, 15);
		panel.add(label_1_2);
		
		textField_3 = new JTextField();
		textField_3.setColumns(10);
		textField_3.setBounds(73, 110, 129, 21);
		panel.add(textField_3);
		
		JLabel label_1_3 = new JLabel("提成比例:");
		label_1_3.setBounds(23, 141, 74, 15);
		panel.add(label_1_3);
		
		JLabel label_1_4 = new JLabel("入职日期 :");
		label_1_4.setBounds(23, 174, 74, 15);
		panel.add(label_1_4);
		
		JSpinner spinner = new JSpinner();
		spinner.setBounds(95, 138, 56, 22);
		panel.add(spinner);
		
		JLabel label_2 = new JLabel("(1%代表提成0.01)");
		label_2.setForeground(Color.BLUE);
		label_2.setBounds(166, 141, 136, 15);
		panel.add(label_2);
		
		//时间插件，导入架包
		DatePicker dp = new DatePicker();
		dp.setBounds(100, 171, 150, 21);
		panel.add(dp);
		
		JLabel label_3 = new JLabel("备 注 :");
		label_3.setBounds(23, 199, 54, 15);
		panel.add(label_3);
		
		JTextPane textPane = new JTextPane();
		textPane.setBounds(73, 199, 229, 132);
		panel.add(textPane);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new TitledBorder(null, "\u5934\u50CF", TitledBorder.LEADING, TitledBorder.TOP, null, null));
		panel_2.setBounds(256, 29, 114, 98);
		panel.add(panel_2);
		panel_2.setLayout(new BorderLayout(0, 0));
		
		JLabel lbl_icon = new JLabel("双击,上传");
		lbl_icon.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				//双击
				if(e.getClickCount()==2) {
					JFileChooser jf = new JFileChooser();
					jf.setFileFilter(new FileNameExtensionFilter("JPG & PNG fiels", "jpg","png"));
					jf.showOpenDialog(null);
					File f = jf.getSelectedFile();
					String path = f.getAbsolutePath();
					ImageIcon icon = new ImageIcon(path);
					icon.setImage(icon.getImage().getScaledInstance(125, 93, 1));
					lbl_icon.setIcon(icon);
				}
			}
		});
		panel_2.add(lbl_icon, BorderLayout.CENTER);
		
		JPanel panel_1 = new JPanel();
		FlowLayout flowLayout = (FlowLayout) panel_1.getLayout();
		flowLayout.setHgap(20);
		flowLayout.setAlignment(FlowLayout.RIGHT);
		contentPane.add(panel_1, BorderLayout.SOUTH);
		
		JButton btnNewButton = new JButton("保 存");
		btnNewButton.setIcon(new ImageIcon(V_empAdd.class.getResource("/images/保存 (1).png")));
		panel_1.add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("取 消");
		btnNewButton_1.setIcon(new ImageIcon(V_empAdd.class.getResource("/images/reset.png")));
		panel_1.add(btnNewButton_1);
	}
}
